package com.sz.security.pojo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * 登录信息
 *
 * @author sz
 * @since 2024/1/22 9:38
 * @version 1.0
 */
@Data
public class LoginInfo {

    @Schema(description = "用户名")
    private String username;

    @Schema(description = "密码")
    private String password;

    @Schema(description = "客户端id", requiredMode = Schema.RequiredMode.REQUIRED)
    private String clientId;

    @Schema(description = "授权类型", requiredMode = Schema.RequiredMode.REQUIRED)
    private String grantType;

    @Schema(description = "账户类型", requiredMode = Schema.RequiredMode.REQUIRED)
    private String userType;

    @Schema(description = "微信小程序登录code")
    private String code;
    
    @Schema(description = "手机号")
    private String phone;
    
    /**
     * 获取登录用户名（兼容手机号登录）
     * @return 用户名或手机号
     */
    public String getLoginUsername() {
        if (username != null && !username.isEmpty()) {
            return username;
        }
        if (phone != null && !phone.isEmpty()) {
            return phone;
        }
        return null;
    }

}